package question

func balancedStringSplit(s string) int {
	ans, LSum, RSum := 0, 0, 0
	sLen := len(s)
	for i := 0; i < sLen; i++ {
		if s[i:i+1] == "L" {
			LSum++
		}
		if s[i:i+1] == "R" {
			RSum++
		}
		if LSum == RSum {
			ans++
		}
	}
	return ans
}
